/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-05-30 10:08:47
 * @LastEditors: voanit
 * @LastEditTime: 2022-05-30 10:54:26
 */
import { TypeChannelAction } from '../actions/channel'

import { Channel } from '../actions/channel'

const initChannel: {
  channelList: Channel[]
  activeId: number
} = {
  channelList: [],
  activeId: 0,
}

export default function channel(
  state = initChannel,
  action: TypeChannelAction
) {
  switch (action.type) {
    case 'channel/getChannelList':
      return {
        ...state, //{channelList: [],activeId: 0,}
        channelList: action.payload,
      }
    case 'channel/changeActive':
      return {
        ...state, //{channelList: [],activeId: 0,}
        activeId: action.payload,
      }
    default:
      return state
  }
}
